//
//  JNavgationBarView.m
//  iBuy
//
//  Created by junFung on 15/10/2.
//  Copyright (c) 2015年 yc. All rights reserved.
//

#import "JNavgationBarView.h"

@implementation JNavgationBarView

- (instancetype)initWithFrame:(CGRect)frame title:(NSString *)title leftTitle:(NSString *)left leftImageNamed:(NSString *)leftImage rightTitle:(NSString *)right rightImageNamed:(NSString *)rightImage
{
    self = [super initWithFrame:frame];
    if (self) {
        //left
        CGFloat buttonH = 44.0;
        CGFloat buttonW = 44.0;
        UIButton * leftButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 20, buttonW, buttonH)];
        [leftButton setTitle:left forState:UIControlStateNormal];
        [leftButton setImage:[UIImage imageNamed:leftImage] forState:UIControlStateNormal];
        [self addSubview:leftButton];
        
        //right
        UIButton *rightButton = [[UIButton alloc] initWithFrame:CGRectMake(frame.size.width-44, 20, buttonW, buttonH)];
        [rightButton setTitle:right forState:UIControlStateNormal];
        [rightButton setImage:[UIImage imageNamed:rightImage] forState:UIControlStateNormal];
        [self addSubview:rightButton];
        
        //标题
        UILabel *labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(buttonW, 20, frame.size.width-buttonW*2, 44)];
        labelTitle.text = title;
        labelTitle.textColor = [UIColor blackColor];
        labelTitle.textAlignment = NSTextAlignmentCenter;
        labelTitle.font = [UIFont systemFontOfSize:16.0];
        [self addSubview:labelTitle];
        
//        self.backgroundColor = [UIColor clearColor];
//        rightButton.backgroundColor = [UIColor redColor];
//        leftButton.backgroundColor = [UIColor redColor];
//        labelTitle.backgroundColor = [UIColor blackColor];
        
    }
    return self;
}

@end
